package com.itheima.tlias.tliasweb.mapper;

import com.github.pagehelper.Page;
import com.itheima.tlias.tliasweb.entity.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {

    @Select("select count(*) from emp")
    int selectTotal();

    @Select("select * from emp limit #{offset}, #{size}")
    List<Emp> selectPage(@Param("offset") int offset, @Param("size")int size);

    Page<Emp> page(@Param("name")String name, @Param("gender")Integer gender,
                   @Param("begin")LocalDate begin, @Param("end")LocalDate end);

    int deleteByIds(@Param("ids") List<Integer> ids);

    int insert(Emp emp);

    @Select("select * from emp where id = #{id}")
    Emp selectById(Integer id);

    int update(Emp emp);

    @Select("select id, username, password from emp where username=#{username}")
    Emp selectByUsername(String username);

    @Delete("delete from emp where dept_id = #{deptId}")
    void deleteByDeptId(Integer deptId);

    // @Select("select * from emp")
    //Page<Emp> page();
}
